<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Reline::Unicode - reline: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-calculate_width">::calculate_width</a>
    <li ><a href="#method-c-ed_transpose_words">::ed_transpose_words</a>
    <li ><a href="#method-c-em_backward_word">::em_backward_word</a>
    <li ><a href="#method-c-em_big_backward_word">::em_big_backward_word</a>
    <li ><a href="#method-c-em_forward_word">::em_forward_word</a>
    <li ><a href="#method-c-em_forward_word_with_capitalization">::em_forward_word_with_capitalization</a>
    <li ><a href="#method-c-escape_for_print">::escape_for_print</a>
    <li ><a href="#method-c-get_mbchar_width">::get_mbchar_width</a>
    <li ><a href="#method-c-get_next_mbchar_size">::get_next_mbchar_size</a>
    <li ><a href="#method-c-get_prev_mbchar_size">::get_prev_mbchar_size</a>
    <li ><a href="#method-c-split_by_width">::split_by_width</a>
    <li ><a href="#method-c-take_range">::take_range</a>
    <li ><a href="#method-c-vi_backward_word">::vi_backward_word</a>
    <li ><a href="#method-c-vi_big_backward_word">::vi_big_backward_word</a>
    <li ><a href="#method-c-vi_big_forward_end_word">::vi_big_forward_end_word</a>
    <li ><a href="#method-c-vi_big_forward_word">::vi_big_forward_word</a>
    <li ><a href="#method-c-vi_first_print">::vi_first_print</a>
    <li ><a href="#method-c-vi_forward_end_word">::vi_forward_end_word</a>
    <li ><a href="#method-c-vi_forward_word">::vi_forward_word</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Reline::Unicode">
    <h1 id="class-Reline::Unicode" class="class">
      class Reline::Unicode
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="CSI_REGEXP">CSI_REGEXP
          <dd>
          <dt id="EscapedChars">EscapedChars
          <dd>
          <dt id="EscapedPairs">EscapedPairs
          <dd>
          <dt id="HalfwidthDakutenHandakuten">HalfwidthDakutenHandakuten
          <dd>
          <dt id="MBCharWidthRE">MBCharWidthRE
          <dd>
          <dt id="NON_PRINTING_END">NON_PRINTING_END
          <dd>
          <dt id="NON_PRINTING_START">NON_PRINTING_START
          <dd>
          <dt id="OSC_REGEXP">OSC_REGEXP
          <dd>
          <dt id="WIDTH_SCANNER">WIDTH_SCANNER
          <dd>
        </dl>
        </section>



                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-calculate_width" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">calculate_width</span><span
                                class="method-args">(str, allow_escape_code = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="calculate_width-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 105</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">calculate_width</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">allow_escape_code</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">allow_escape_code</span>
    <span class="ruby-identifier">width</span> = <span class="ruby-value">0</span>
    <span class="ruby-identifier">rest</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>)
    <span class="ruby-identifier">in_zero_width</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-identifier">rest</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-constant">WIDTH_SCANNER</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">non_printing_start</span>, <span class="ruby-identifier">non_printing_end</span>, <span class="ruby-identifier">csi</span>, <span class="ruby-identifier">osc</span>, <span class="ruby-identifier">gc</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">case</span>
      <span class="ruby-keyword">when</span> <span class="ruby-identifier">non_printing_start</span>
        <span class="ruby-identifier">in_zero_width</span> = <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">when</span> <span class="ruby-identifier">non_printing_end</span>
        <span class="ruby-identifier">in_zero_width</span> = <span class="ruby-keyword">false</span>
      <span class="ruby-keyword">when</span> <span class="ruby-identifier">csi</span>, <span class="ruby-identifier">osc</span>
      <span class="ruby-keyword">when</span> <span class="ruby-identifier">gc</span>
        <span class="ruby-keyword">unless</span> <span class="ruby-identifier">in_zero_width</span>
          <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">gc</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">width</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">str</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>).<span class="ruby-identifier">grapheme_clusters</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">0</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">w</span>, <span class="ruby-identifier">gc</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">w</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">gc</span>)
    }
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-ed_transpose_words" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ed_transpose_words</span><span
                                class="method-args">(line, byte_pointer)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="ed_transpose_words-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 307</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">ed_transpose_words</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-identifier">right_word_start</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span>, <span class="ruby-identifier">size</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span>.<span class="ruby-identifier">zero?</span>
    <span class="ruby-comment"># &#39; aaa bbb [cursor]&#39;</span>
    <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
    <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\p{Word}/</span>
      <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-=</span> <span class="ruby-identifier">size</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\P{Word}/</span>
      <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-=</span> <span class="ruby-identifier">size</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">right_word_start</span> = <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>
    <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
    <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\P{Word}/</span>
      <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">after_start</span> = <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\p{Word}/</span>
    <span class="ruby-comment"># &#39; aaa bb[cursor]b&#39;</span>
    <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
    <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\P{Word}/</span>
      <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-=</span> <span class="ruby-identifier">size</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">right_word_start</span> = <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>
    <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
    <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\P{Word}/</span>
      <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">after_start</span> = <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
    <span class="ruby-keyword">while</span> (<span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\p{Word}/</span>
      <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>) <span class="ruby-operator">==</span> (<span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)
      <span class="ruby-comment"># &#39; aaa bbb [cursor] &#39;</span>
      <span class="ruby-identifier">after_start</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span>
      <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
        <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
        <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
        <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\p{Word}/</span>
        <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-=</span> <span class="ruby-identifier">size</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
        <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
        <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
        <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\P{Word}/</span>
        <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-=</span> <span class="ruby-identifier">size</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">right_word_start</span> = <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-comment"># &#39; aaa [cursor] bbb &#39;</span>
      <span class="ruby-identifier">right_word_start</span> = <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>
      <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
        <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
        <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
        <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\P{Word}/</span>
        <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">after_start</span> = <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">byte_size</span> = <span class="ruby-identifier">right_word_start</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_pointer</span>
  <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\p{Word}/</span>
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">middle_start</span> = <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>
  <span class="ruby-identifier">byte_size</span> = <span class="ruby-identifier">middle_start</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_pointer</span>
  <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\P{Word}/</span>
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">left_word_start</span> = <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>
  [<span class="ruby-identifier">left_word_start</span>, <span class="ruby-identifier">middle_start</span>, <span class="ruby-identifier">right_word_start</span>, <span class="ruby-identifier">after_start</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-em_backward_word" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">em_backward_word</span><span
                                class="method-args">(line, byte_pointer)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="em_backward_word-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 267</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">em_backward_word</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-identifier">width</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
  <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\p{Word}/</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\P{Word}/</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  [<span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">width</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-em_big_backward_word" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">em_big_backward_word</span><span
                                class="method-args">(line, byte_pointer)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="em_big_backward_word-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 287</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">em_big_backward_word</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-identifier">width</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
  <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\S/</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\s/</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  [<span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">width</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-em_forward_word" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">em_forward_word</span><span
                                class="method-args">(line, byte_pointer)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="em_forward_word-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 218</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">em_forward_word</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-identifier">width</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\p{Word}/</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\P{Word}/</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  [<span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">width</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-em_forward_word_with_capitalization" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">em_forward_word_with_capitalization</span><span
                                class="method-args">(line, byte_pointer)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="em_forward_word_with_capitalization-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 238</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">em_forward_word_with_capitalization</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-identifier">width</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">new_str</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\p{Word}/</span>
    <span class="ruby-identifier">new_str</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">mbchar</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">first</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\P{Word}/</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">first</span>
      <span class="ruby-identifier">new_str</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">upcase</span>
      <span class="ruby-identifier">first</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">new_str</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">downcase</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  [<span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">width</span>, <span class="ruby-identifier">new_str</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-escape_for_print" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">escape_for_print</span><span
                                class="method-args">(str)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="escape_for_print-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 44</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">escape_for_print</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">chars</span>.<span class="ruby-identifier">map!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">gr</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">escaped</span> = <span class="ruby-constant">EscapedPairs</span>[<span class="ruby-identifier">gr</span>.<span class="ruby-identifier">ord</span>]
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">escaped</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">gr</span> <span class="ruby-operator">!=</span> <span class="ruby-string">-&quot;\n&quot;</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">gr</span> <span class="ruby-operator">!=</span> <span class="ruby-string">-&quot;\t&quot;</span>
      <span class="ruby-identifier">escaped</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">gr</span>
    <span class="ruby-keyword">end</span>
  }.<span class="ruby-identifier">join</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-get_mbchar_width" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">get_mbchar_width</span><span
                                class="method-args">(mbchar)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="get_mbchar_width-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 85</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
  <span class="ruby-identifier">ord</span> = <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">ord</span>
  <span class="ruby-keyword">if</span> (<span class="ruby-value">0x00</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">ord</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">ord</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0x1F</span>) <span class="ruby-comment"># in EscapedPairs</span>
    <span class="ruby-keyword">return</span> <span class="ruby-value">2</span>
  <span class="ruby-keyword">elsif</span> (<span class="ruby-value">0x20</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">ord</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">ord</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0x7E</span>) <span class="ruby-comment"># printable ASCII chars</span>
    <span class="ruby-keyword">return</span> <span class="ruby-value">1</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">m</span> = <span class="ruby-identifier">mbchar</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>).<span class="ruby-identifier">match</span>(<span class="ruby-constant">MBCharWidthRE</span>)
  <span class="ruby-keyword">case</span>
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">then</span> <span class="ruby-value">1</span> <span class="ruby-comment"># TODO should be U+FFFD � REPLACEMENT CHARACTER</span>
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">:width_2_1</span>], <span class="ruby-identifier">m</span>[<span class="ruby-value">:width_2_2</span>], <span class="ruby-identifier">m</span>[<span class="ruby-value">:width_2_3</span>] <span class="ruby-keyword">then</span> <span class="ruby-value">2</span>
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">:width_3</span>] <span class="ruby-keyword">then</span> <span class="ruby-value">3</span>
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">:width_0</span>] <span class="ruby-keyword">then</span> <span class="ruby-value">0</span>
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">:width_1</span>] <span class="ruby-keyword">then</span> <span class="ruby-value">1</span>
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">:ambiguous_width</span>] <span class="ruby-keyword">then</span> <span class="ruby-constant">Reline</span>.<span class="ruby-identifier">ambiguous_width</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-get_next_mbchar_size" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">get_next_mbchar_size</span><span
                                class="method-args">(line, byte_pointer)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="get_next_mbchar_size-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 204</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-identifier">grapheme</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>).<span class="ruby-identifier">grapheme_clusters</span>.<span class="ruby-identifier">first</span>
  <span class="ruby-identifier">grapheme</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">grapheme</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-get_prev_mbchar_size" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">get_prev_mbchar_size</span><span
                                class="method-args">(line, byte_pointer)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="get_prev_mbchar_size-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 209</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">byte_pointer</span>.<span class="ruby-identifier">zero?</span>
    <span class="ruby-value">0</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">grapheme</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-value">0</span><span class="ruby-operator">..</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)).<span class="ruby-identifier">grapheme_clusters</span>.<span class="ruby-identifier">last</span>
    <span class="ruby-identifier">grapheme</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">grapheme</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-split_by_width" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">split_by_width</span><span
                                class="method-args">(str, max_width, encoding = str.encoding)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="split_by_width-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 131</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">split_by_width</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">max_width</span>, <span class="ruby-identifier">encoding</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">encoding</span>)
  <span class="ruby-identifier">lines</span> = [<span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">encoding:</span> <span class="ruby-identifier">encoding</span>)]
  <span class="ruby-identifier">height</span> = <span class="ruby-value">1</span>
  <span class="ruby-identifier">width</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">rest</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>)
  <span class="ruby-identifier">in_zero_width</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">seq</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">encoding:</span> <span class="ruby-identifier">encoding</span>)
  <span class="ruby-identifier">rest</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-constant">WIDTH_SCANNER</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">non_printing_start</span>, <span class="ruby-identifier">non_printing_end</span>, <span class="ruby-identifier">csi</span>, <span class="ruby-identifier">osc</span>, <span class="ruby-identifier">gc</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">case</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">non_printing_start</span>
      <span class="ruby-identifier">in_zero_width</span> = <span class="ruby-keyword">true</span>
      <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">NON_PRINTING_START</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">non_printing_end</span>
      <span class="ruby-identifier">in_zero_width</span> = <span class="ruby-keyword">false</span>
      <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">NON_PRINTING_END</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">csi</span>
      <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">csi</span>
      <span class="ruby-identifier">seq</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">csi</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">osc</span>
      <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">osc</span>
      <span class="ruby-identifier">seq</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">osc</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">gc</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">in_zero_width</span>
        <span class="ruby-identifier">mbchar_width</span> = <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">gc</span>)
        <span class="ruby-keyword">if</span> (<span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">mbchar_width</span>) <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">max_width</span>
          <span class="ruby-identifier">width</span> = <span class="ruby-identifier">mbchar_width</span>
          <span class="ruby-identifier">lines</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">nil</span>
          <span class="ruby-identifier">lines</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">seq</span>.<span class="ruby-identifier">dup</span>
          <span class="ruby-identifier">height</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">gc</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-comment"># The cursor moves to next line in first</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">width</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">max_width</span>
    <span class="ruby-identifier">lines</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">nil</span>
    <span class="ruby-identifier">lines</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">encoding:</span> <span class="ruby-identifier">encoding</span>)
    <span class="ruby-identifier">height</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
  <span class="ruby-keyword">end</span>
  [<span class="ruby-identifier">lines</span>, <span class="ruby-identifier">height</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-take_range" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">take_range</span><span
                                class="method-args">(str, start_col, max_width)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Take a chunk of a String cut by width with escape sequences.</p>

                              <div class="method-source-code" id="take_range-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 175</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">take_range</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">start_col</span>, <span class="ruby-identifier">max_width</span>)
  <span class="ruby-identifier">chunk</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">encoding:</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">encoding</span>)
  <span class="ruby-identifier">total_width</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">rest</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>)
  <span class="ruby-identifier">in_zero_width</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">rest</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-constant">WIDTH_SCANNER</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">non_printing_start</span>, <span class="ruby-identifier">non_printing_end</span>, <span class="ruby-identifier">csi</span>, <span class="ruby-identifier">osc</span>, <span class="ruby-identifier">gc</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">case</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">non_printing_start</span>
      <span class="ruby-identifier">in_zero_width</span> = <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">non_printing_end</span>
      <span class="ruby-identifier">in_zero_width</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">csi</span>
      <span class="ruby-identifier">chunk</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">csi</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">osc</span>
      <span class="ruby-identifier">chunk</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">osc</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">gc</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">in_zero_width</span>
        <span class="ruby-identifier">chunk</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">gc</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">mbchar_width</span> = <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">gc</span>)
        <span class="ruby-identifier">total_width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">mbchar_width</span>
        <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> (<span class="ruby-identifier">start_col</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">max_width</span>) <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">total_width</span>
        <span class="ruby-identifier">chunk</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">gc</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">start_col</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">total_width</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">chunk</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-vi_backward_word" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">vi_backward_word</span><span
                                class="method-args">(line, byte_pointer)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="vi_backward_word-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 596</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">vi_backward_word</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-identifier">width</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
  <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\S/</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\w/</span>
        <span class="ruby-identifier">started_by</span> = <span class="ruby-value">:word</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">started_by</span> = <span class="ruby-value">:non_word_printable</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">started_by</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:word</span>
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\W/</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:non_word_printable</span>
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/[\w\s]/</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  [<span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">width</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-vi_big_backward_word" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">vi_big_backward_word</span><span
                                class="method-args">(line, byte_pointer)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="vi_big_backward_word-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 458</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">vi_big_backward_word</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-identifier">width</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
  <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\S/</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_prev_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\s/</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  [<span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">width</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-vi_big_forward_end_word" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">vi_big_forward_end_word</span><span
                                class="method-args">(line, byte_pointer)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="vi_big_forward_end_word-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 428</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">vi_big_forward_end_word</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-keyword">if</span> (<span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">byte_pointer</span>
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-identifier">width</span> = <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> = <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">return</span> [<span class="ruby-value">0</span>, <span class="ruby-value">0</span>]
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">while</span> (<span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\S/</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">prev_width</span> = <span class="ruby-identifier">width</span>
  <span class="ruby-identifier">prev_byte_size</span> = <span class="ruby-identifier">byte_size</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\s/</span>
    <span class="ruby-identifier">prev_width</span> = <span class="ruby-identifier">width</span>
    <span class="ruby-identifier">prev_byte_size</span> = <span class="ruby-identifier">byte_size</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  [<span class="ruby-identifier">prev_byte_size</span>, <span class="ruby-identifier">prev_width</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-vi_big_forward_word" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">vi_big_forward_word</span><span
                                class="method-args">(line, byte_pointer)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="vi_big_forward_word-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 408</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">vi_big_forward_word</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-identifier">width</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
  <span class="ruby-keyword">while</span> (<span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\s/</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">while</span> (<span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\S/</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  [<span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">width</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-vi_first_print" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">vi_first_print</span><span
                                class="method-args">(line)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="vi_first_print-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 628</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">vi_first_print</span>(<span class="ruby-identifier">line</span>)
  <span class="ruby-identifier">width</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">byte_size</span> = <span class="ruby-value">0</span>
  <span class="ruby-keyword">while</span> (<span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">byte_size</span>
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\S/</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  [<span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">width</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-vi_forward_end_word" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">vi_forward_end_word</span><span
                                class="method-args">(line, byte_pointer)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="vi_forward_end_word-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 519</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">vi_forward_end_word</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
  <span class="ruby-keyword">if</span> (<span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">byte_pointer</span>
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\w/</span>
      <span class="ruby-identifier">started_by</span> = <span class="ruby-value">:word</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\s/</span>
      <span class="ruby-identifier">started_by</span> = <span class="ruby-value">:space</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">started_by</span> = <span class="ruby-value">:non_word_printable</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">width</span> = <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> = <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">return</span> [<span class="ruby-value">0</span>, <span class="ruby-value">0</span>]
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> (<span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\w/</span>
      <span class="ruby-identifier">second</span> = <span class="ruby-value">:word</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\s/</span>
      <span class="ruby-identifier">second</span> = <span class="ruby-value">:space</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">second</span> = <span class="ruby-value">:non_word_printable</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">second_width</span> = <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">second_byte_size</span> = <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">return</span> [<span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">width</span>]
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">second</span> <span class="ruby-operator">==</span> <span class="ruby-value">:space</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">second_width</span>
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">second_byte_size</span>
    <span class="ruby-keyword">while</span> (<span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
      <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\S/</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\w/</span>
          <span class="ruby-identifier">started_by</span> = <span class="ruby-value">:word</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">started_by</span> = <span class="ruby-value">:non_word_printable</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">break</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
      <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">case</span> [<span class="ruby-identifier">started_by</span>, <span class="ruby-identifier">second</span>]
    <span class="ruby-keyword">when</span> [<span class="ruby-value">:word</span>, <span class="ruby-value">:non_word_printable</span>], [<span class="ruby-value">:non_word_printable</span>, <span class="ruby-value">:word</span>]
      <span class="ruby-identifier">started_by</span> = <span class="ruby-identifier">second</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">second_width</span>
      <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">second_byte_size</span>
      <span class="ruby-identifier">started_by</span> = <span class="ruby-identifier">second</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">prev_width</span> = <span class="ruby-identifier">width</span>
  <span class="ruby-identifier">prev_byte_size</span> = <span class="ruby-identifier">byte_size</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">started_by</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:word</span>
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\W/</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:non_word_printable</span>
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/[\w\s]/</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">prev_width</span> = <span class="ruby-identifier">width</span>
    <span class="ruby-identifier">prev_byte_size</span> = <span class="ruby-identifier">byte_size</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  [<span class="ruby-identifier">prev_byte_size</span>, <span class="ruby-identifier">prev_width</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-vi_forward_word" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">vi_forward_word</span><span
                                class="method-args">(line, byte_pointer, drop_terminate_spaces = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="vi_forward_word-source">
            <pre><span class="ruby-comment"># File reline/unicode.rb, line 478</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">vi_forward_word</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>, <span class="ruby-identifier">drop_terminate_spaces</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">byte_pointer</span>
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\w/</span>
      <span class="ruby-identifier">started_by</span> = <span class="ruby-value">:word</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\s/</span>
      <span class="ruby-identifier">started_by</span> = <span class="ruby-value">:space</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">started_by</span> = <span class="ruby-value">:non_word_printable</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">width</span> = <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> = <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">return</span> [<span class="ruby-value">0</span>, <span class="ruby-value">0</span>]
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">started_by</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:word</span>
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\W/</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:space</span>
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\S/</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:non_word_printable</span>
      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\w|\s/</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> [<span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">width</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">drop_terminate_spaces</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">get_next_mbchar_size</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>)
    <span class="ruby-identifier">mbchar</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">byte_pointer</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">size</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mbchar</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\S/</span>
    <span class="ruby-identifier">width</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_mbchar_width</span>(<span class="ruby-identifier">mbchar</span>)
    <span class="ruby-identifier">byte_size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  [<span class="ruby-identifier">byte_size</span>, <span class="ruby-identifier">width</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

